refactor: migrate lib.autoExternal to output.autoExternal - #1641
Conversation
Deploying rslib with
|
| Latest commit: |
c5fb629
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://26c51f88.rslib.pages.dev |
| Branch Preview URL: | https://refactor-migrate-auto-extern.rslib.pages.dev |
b2e6446 to
1a5b36f
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates Rslib’s dependency auto-externalization behavior from the legacy lib.autoExternal option to Rsbuild’s output.autoExternal, aligning implementation with Rsbuild’s built-in capability while keeping backward compatibility via a deprecation shim.
Changes:
- Add
output.autoExternaldocumentation (EN/ZH) and marklib.autoExternalas deprecated in docs and public config typings. - Refactor core config composition to rely on
output.autoExternal(and remove the previous customcomposeAutoExternalConfigimplementation and its unit tests). - Update CLI option wiring and test expectations/snapshots to reflect the new configuration location.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/zh/config/rsbuild/output.mdx | Add output.autoExternal docs and update output.externals wording to reference it. |
| website/docs/zh/config/lib/auto-external.mdx | Add deprecation warning pointing to output.autoExternal. |
| website/docs/en/config/rsbuild/output.mdx | Add output.autoExternal docs and update output.externals wording to reference it. |
| website/docs/en/config/lib/auto-external.mdx | Add deprecation warning pointing to output.autoExternal. |
| tests/integration/externals/index.test.ts | Remove the module-import warning integration test that depended on the old warning logic. |
| tests/integration/auto-external/index.test.ts | Remove the module-import warning integration test and simplify imports accordingly. |
| packages/core/tests/external.test.ts | Remove unit tests for the deleted composeAutoExternalConfig. |
| packages/core/tests/config.test.ts | Update CLI snapshot expectations for new output.autoExternal location. |
| packages/core/tests/cli.test.ts | Assert CLI populates lib.output.autoExternal instead of lib.autoExternal. |
| packages/core/tests/snapshots/config.test.ts.snap | Update snapshots to reflect externals ordering and output.autoExternal presence. |
| packages/core/src/types/config.ts | Deprecate lib.autoExternal in typings and add output.autoExternal override typing/docs. |
| packages/core/src/config.ts | Remove custom auto-externalization + warning logic; set defaults via output.autoExternal; add deprecation shim. |
| packages/core/src/cli/init.ts | Wire --auto-external CLI flag to lib.output.autoExternal. |
Comments suppressed due to low confidence (2)
website/docs/en/config/lib/auto-external.mdx:15
- The page frontmatter/intro still describes
lib.autoExternalas an active configuration, but the option is now deprecated. Update the page description/intro to clearly state it’s kept for backward compatibility and point readers tooutput.autoExternalas the canonical option.
# lib.autoExternal
:::warning
`lib.autoExternal` is deprecated. Please use [output.autoExternal](/config/rsbuild/output#outputautoexternal) instead.
:::
:::info
`autoExternal` is a specific configuration for bundle mode. It will not take effect in bundleless mode (set [lib.bundle](/config/lib/bundle) to `false`) since deps will not be bundled in bundleless mode.
website/docs/zh/config/lib/auto-external.mdx:15
- 当前页面的描述仍然把
lib.autoExternal当作主要配置项,但这里已标记为废弃。建议同步更新页面的描述/开头说明,明确这是兼容性保留配置,并引导用户迁移到output.autoExternal。
# lib.autoExternal
:::warning
`lib.autoExternal` 已废弃,请使用 [output.autoExternal](/config/rsbuild/output#outputautoexternal) 代替。
:::
:::info
`autoExternal` 是 bundle 模式的特定配置。在 bundleless 模式(将 [lib.bundle](/config/lib/bundle) 设置为 `false`)下不会生效,因为 bundleless 模式下依赖不会被打包。
lib.autoExternal to output.autoExternal to leverage Rsbuild's capabilitylib.autoExternal to output.autoExternal
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71232855db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
7123285 to
99d1fa6
Compare
Co-Authored-By: Aiden
…-external-to-rsbuild
…-external-to-rsbuild
…-external-to-rsbuild # Conflicts: # packages/core/src/config.ts
…-external-to-rsbuild # Conflicts: # packages/core/src/config.ts # packages/core/tests/__snapshots__/config.test.ts.snap # tests/integration/externals/index.test.ts
…-external-to-rsbuild
dcc6c66 to
003de77
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5fb629875
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| libConfig.autoExternal !== undefined && | ||
| libConfig.output?.autoExternal === undefined |
There was a problem hiding this comment.
Preserve shared deprecated autoExternal settings
When users still rely on the documented top-level deprecated setting, e.g. autoExternal: false as a shared lib option, this shim never copies it into userConfig.output.autoExternal because it only checks the per-lib item. The merged userConfig.autoExternal is later omitted from the final Rsbuild config, while composeFormatConfig adds output.autoExternal: true for ESM/CJS, so those projects silently start externalizing dependencies instead of bundling them.
Useful? React with 👍 / 👎.
| autoExternal: | ||
| libConfig.output?.autoExternal ?? | ||
| libConfig.autoExternal ?? | ||
| isIntermediateOutputFormat(format), |
There was a problem hiding this comment.
Honor autoExternal exclude/packageJson for bundled dts
When dts.bundle is enabled and users configure Rsbuild-only options such as output.autoExternal: { exclude: ['foo'] } or packageJson, passing this object straight through makes rsbuild-plugin-dts ignore those fields: its bundled-package calculation only understands dependency booleans and always reads the root package.json. The JS build will bundle excluded packages (or read a different package file), but the declaration bundle will still treat them as external, so emitted types no longer match the JS dependency handling unless users manually duplicate dts.bundle.bundledPackages.
Useful? React with 👍 / 👎.
Migrated
lib.autoExternalto reuse Rsbuild's nativeoutput.autoExternal(available since Rsbuild 2.0.7).The deprecated
lib.autoExternalfield is preserved that maps tooutput.autoExternalwith a deprecation warning.